package Model;

import java.io.Serializable;

import Messaging.Notification;
import Messaging.NotificationManager;

/* 
 * @author Mark de Lira
 */
public class UpgradeablePropertySpace extends PropertySpace implements Serializable 
{
	
	final static long serialVersionUID = 228;
	
	public UpgradeablePropertySpace() 
	{
		Name_ = "NONE";
		State_ = SpaceUnowned.Instance();
		purchasePrice_ = 0;
		mortgageValue_ = 0;
		rentValues_ = new int[6];
		Owner_ = null;
	}
	
	public UpgradeablePropertySpace(String name, int type, int spaceNumber, int purchasePrice, 
			int mortgageValue, int rent0, int rent1, int rent2, int rent3, int rent4, int rent5)
	{
		
		Name_ = name;
		State_ = SpaceUnowned.Instance();
		purchasePrice_ = purchasePrice;
		mortgageValue_ = mortgageValue;
		rentValues_ = new int[6];
		rentValues_[0] = rent0;
		rentValues_[1] = rent1;
		rentValues_[2] = rent2; 
		rentValues_[3] = rent3;
		rentValues_[4] = rent4;
		rentValues_[5] = rent5;
		
		Type_ = type;
		SpaceNumber_ = spaceNumber;
		
		Owner_ = null;
	}
	
	public UpgradeablePropertySpace(UpgradeablePropertySpace space)
	{
		Name_ = space.getName();
		State_ = space.getState();
		purchasePrice_ = space.getPurchasePrice();
		mortgageValue_ = space.getMortgageValue();
		rentValues_ = new int[6];
		rentValues_[0] = space.getRentValues()[0];
		rentValues_[1] = space.getRentValues()[1];
		rentValues_[2] = space.getRentValues()[2];
		rentValues_[3] = space.getRentValues()[3];
		rentValues_[4] = space.getRentValues()[4];
		rentValues_[5] = space.getRentValues()[5];
		
		Type_ = space.getTypeInt();
		SpaceNumber_ = space.getSpaceNumber();
		
		Owner_ = space.getOwner();
	}
	
	public void changeState(SpaceState newState)
	{
		State_ = newState;
	}
	
	public SpaceState getState()
	{
		return State_;
	}
	
	public void landOn(Player p)
	{
		State_.landOn(p, this);
	}

	public void setPurchasePrice(int purchasePrice)
	{
		purchasePrice_ = purchasePrice;
	}

	public int getPurchasePrice()
	{
		return purchasePrice_;
	}
	
	public void setMortgageValue(int mortgageValue) 
	{
		mortgageValue_ = mortgageValue;
	}

	public int getMortgageValue() 
	{
		return mortgageValue_;
	}

	public void setRentValues(int[] rentValues) 
	{
		rentValues_ = rentValues;
	}

	public int[] getRentValues()
	{
		return rentValues_;
	}
	
	public void setOwner(Player p)
	{
		Owner_ = p;
		NotificationManager.getInstance().notifyObservers(Notification.CHANGED_OWNER, this);
	}
	
	public Player getOwner()
	{
		return Owner_;
	}
	
	public boolean isUpgradeable()
	{
		return State_.isUpgradeable(this);
	}
	
	public boolean isDowngradeable() 
	{
		return State_.isDowngradeable(this);
	}
	
	public boolean isRenovated() 
	{
		return State_.isRenovated(this);
	}
	
	public void bePurchased(Player owner) 
	{
		setOwner(owner);
		State_.changeState(this, PropertyOwned.Instance());
	}
	
	public void renovate()
	{
		State_.renovate(this);
	}
	
	public void downgrade()
	{
		State_.downgrade(this);
	}
	
	public void beMortgaged()
	{
		State_.changeState(this, SpaceMortgaged.Instance());
	}
	
	public void unmortgage()
	{
		State_.changeState(this, PropertyOwned.Instance());
	}
	
	public void ownershipIncrease()
	{

	}
	
	public void ownershipDecrease()
	{
		
	}
}
